'use strict';

var mongoose = require('mongoose'),
    Schema = mongoose.Schema,
    baseController = require('../../../Base/server/controllers/BaseDoc.js');

var newModel = baseController.getBaseDocFields();
//工艺路线
newModel.Routing = {
    type: Schema.ObjectId,
    ref: 'Routing'
};
//序号
newModel.Sequence = {
    type: Number
};
//工序名称
newModel.Name = {
    type: String,
    default:'',
    trim: true
};
//标准作业
newModel.Work = {
    type: Schema.ObjectId,
    ref: 'Work'
};
//是否计时
newModel.IsTiming = {
    type: Boolean,
    default: false
};
//准备工时
newModel.ReadyWorkHours = {
    type: Number
};
//加工工时
newModel.MachinWorkHours = {
    type: Number
};
//是否质检点
newModel.IsQCpoint = {
    type: Boolean,
    default: false
};
newModel.ErpId = {
    type: String,
    trim: true
};
//允许扫描次数
newModel.ScanCounts = {
    type: Number
};
newModel.IsEffective = {
    type: Boolean
};

var newSchema = new Schema(newModel);
newSchema.index({Routing: 1, Sequence: 1}, {"unique": true});

mongoose.model('Operation', newSchema, 'Operation');
